<?php
/*
 * Created on 18 d�c. 2008
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
include_once("Commons.php");
include_once("AlbumCommons.php");



$TypeAds = 0;
$ColsNumber = 2;



printHeader( getTerm('base', 'site_name') , getTerm('home', 'welcome') , 'home');
print '
<script type="text/javascript"><!--
google_ad_client = "pub-2652372001711469";
/* home - top */
google_ad_slot = "7775447933";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';


$sql = "SELECT u.username, YEAR(CURDATE()) - YEAR(p.birthday) - IF( RIGHT(CURDATE(),5) < RIGHT(p.birthday,5) , 1, 0 ) AS 'age', p.gender, p.description, c.name AS 'country', p.photo, ph.type
		FROM user u
		JOIN profile p ON p.user=u.id AND p.current=1
		JOIN region c ON p.country=c.id
		LEFT JOIN photo ph ON p.photo=ph.id
		WHERE u.banned=0
		ORDER BY u.id DESC
		LIMIT 5;";

$rh = query($sql);

if ( mysql_num_rows($rh)>0 )
{
	print '<div id="latest-penpals" class="box"><h3>'. getTerm('home','latest_penpals') .'</h3>';
	while ( $latestUser = mysql_fetch_array($rh) )
	{
		$profileurl = formatUrl("/profile/${latestUser[username]}");
		print '<div class="profile">';

		if ( !empty($latestUser['photo']) )
			print '<a href="'. $profileurl .'"><img class="photo" src="/Thumbs/'. $latestUser['photo'] .'-small.'. strtolower($latestUser['type']) .'" alt="'. fill(getTerm('profile', 'user_photo'), $latestUser['username']) .'" /></a>';

		print '<div class="username"><a href="'. $profileurl .'">'. $latestUser['username'] .'</a></div>';
		print '<div class="overview">'. fill( getTerm('profile', 'user_overview'), $latestUser['age'], getTerm('profile', $latestUser['gender']), getTerm('country', $latestUser['country']) ) .'</div>';
		print '</div>';
	}
	print '</div>';
}


$latestPhotos = getLatestPhotos();

?>
		
		<div id="otherPhotosOverview">
		<p>
		

<script type="text/javascript"><!--
google_ad_client = "pub-2652372001711469";
/* home - top */
google_ad_slot = "7775447933";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
		
			<h3><?= getTerm('home', 'latest_shared_photos') ?></h3>
			
			<ul>
			<?php foreach ($latestPhotos as $photo) { ?>
				
				<li id="photo-<?= $photo['id'] ?>">
					<a href="<?= formatUrl("/albums/${photo[username]}/${photo[albumPath]}/${photo[path]}.html") ?>">
						<img src="/Thumbs/<?= $photo['id'] ?>-square.jpg" width="100" alt="<?= $photo['name'] ?>" title="<?= $photo['name'] ?>" />
					</a>
				</li>
				
			<?php } ?>
			</ul>
		
		</p>
		</div>
		
		<div style="clear:both;"></div>
		
<?php

print '<div id="popular-countries" class="box"><h3>'. getTerm('home','popular_countries') .'</h3><ol>';

$sql = "SELECT s.value, c.name,COUNT(*) AS 'counter'
		FROM searchparameters s
		JOIN region c ON c.id=s.value
		WHERE s.parameter=1
		AND c.is_country=1
		GROUP BY s.value
		ORDER BY counter DESC LIMIT 10;";
		
$rh = query($sql);
while ( $country = mysql_fetch_array($rh) )
{
	print '<li><a href="'. getRegionUrl( $country['name'] ) .'">'. getTerm('country', $country['name']) .'</a></li>';
}

print '</ol></div>';

print '
<script type="text/javascript"><!--
google_ad_client = "pub-2652372001711469";
/* home - top */
google_ad_slot = "7775447933";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';

printExtra();

print '<div id="welcome" class="text-box" id="welcome-text">';
print getTerm('home', 'welcome_text');
print '</div>';

if ( ! isIdentified() )
{
	print '<div class="flat urgent">';
	print '<strong><a href="'. formatUrl('/signin') .'">'. getTerm('extra', 'register_now') .'</a></strong><br/>'. getTerm('extra', 'register_hint');
	print '</div>';
}
else
{
	$currentUser = getCurrentUser();
	if ( ! hasPhoto($currentUser['id']) )
		print '<div class="flat urgent"><strong><a href="'. formatUrl('/account/photo/') .'">'. getTerm('extra', 'upload_photo') .'</a></strong><br/>'. getTerm('extra', 'upload_photo_text') .'<br/>'. getTerm('extra', 'upload_photo_link') .'</div>';
}

printQuickSearch();



print '<div class="flat">';
print '<strong><a href="'. formatUrl('/messaging/') .'">'. getTerm('extra', 'messaging') .'</a></strong><br/>'. getTerm('extra', 'messaging_hint');
print '</div>';

print '<div class="flat">';
print '<strong><a href="'. formatUrl('/friends/') .'">'. getTerm('extra', 'friend_list') .'</a></strong><br/>'. getTerm('extra', 'friend_list_hint');



print '</div>';

print '<br>';

print '<br>';
print '<br>';
print '<br>';

print '<br>';
print '<br>';



printFooter();
 
?>
